<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * 借书表控制器
 */
class Borrow extends AdminBase
{
    
    /**
     * 借书表列表
     */
    public function borrowList()
    {
         $where = [];
        
        !empty($this->param['search_data']) && $where['s_id'] = ['like', (string)$this->param['search_data']];
        
        $this->assign('list', $this->logicBorrow->getBorrowList($where, true, 's_id'));
        
        return $this->fetch('borrow_list');
    }
    
    /**
     * 借书表添加
     */
    public function borrowAdd()
    {
        IS_POST && $this->jump($this->logicBorrow->borrowEdit($this->param));
        
        return $this->fetch('borrow_edit');
    }
    
    /**
     * 借书表编辑
     */
    public function borrowEdit()
    {
       
        IS_POST && $this->jump($this->logicBorrow->borrowEdit($this->param));
        
        $info = $this->logicBook->getBookInfo(['b_id' => $this->param['b_id']]);
        
        $this->assign('info', $info);
        
        return $this->fetch('borrow_edit');
    }

    /**
     * 借书表编辑
     */
    public function backEdit()
    {
       
        IS_POST && $this->jump($this->logicBorrow->backEdit($this->param));

        $info1 = $this->logicBook->getBookInfo(['b_id' => $this->param['b_id']]);
        
        $info = $this->logicBorrow->getBorrowInfo(['b_id' => $this->param['b_id']]);
        
        $this->assign('info1', $info1);
        $this->assign('info', $info);
        
        return $this->fetch('back_edit');
    }

    
    /**
     * 借书表删除
     */
    public function borrowDel($id = 0)
    {
        
        $this->jump($this->logicBorrow->borrowDel(['id' => $id]));
    }
}
